package com.bytebuddytest.custominstrumentation;

import net.bytebuddy.dynamic.scaffold.InstrumentedType;
import net.bytebuddy.implementation.Implementation;
import net.bytebuddy.implementation.bytecode.ByteCodeAppender;

/**
 * @author yutianhong
 * @version 1.0
 * @since 2023/12/28 17:04
 */
public enum SumImplementation implements Implementation {

    INSTANCE; // singleton

    @Override
    public InstrumentedType prepare(InstrumentedType instrumentedType) {
        // 可以对需要增强的类型进行修改或增加新的元素，比如添加字段、方法或接口等
        return instrumentedType;
    }

    @Override
    public ByteCodeAppender appender(Target implementationTarget) {
        // 负责将字节码附加到方法中
        return SumMethod.INSTANCE;
    }
}